#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_bitfield() {
        let c_size_of = unsafe { size_of_three_byte_date() };

        // Ensure correct size (also a packed struct)
        assert_eq!(size_of::<three_byte_date>(), c_size_of);

        // Test zeroed bitfield struct
        let mut tbd = unsafe { zeroed_three_byte_date() };

        tbd.set_day(26);
        tbd.set_month(4);
        tbd.set_year(2019);

        assert_eq!(tbd.day(), 26);
        assert_eq!(tbd.month(), 4);
        assert_eq!(tbd.year(), 2019);

        // Ensure C byte compatibility
        let ret_code = unsafe { compare_three_byte_date(&tbd, 26, 4, 2019) };

        assert_eq!(ret_code, 0);

        // Ensure translated struct ptr reads work
        let rust_ret_code = unsafe { rust_compare_three_byte_date(&tbd, 26, 4, 2019) };

        assert_eq!(rust_ret_code, 0);

        // Ensure can read from C written data
        unsafe { write_three_byte_date(&mut tbd, 24, 12, 2018) }

        assert_eq!(tbd.day(), 24);
        assert_eq!(tbd.month(), 12);
        assert_eq!(tbd.year(), 2018);
    }
}